//Firefox profiles
import java.util.List;
import java.util.concurrent.TimeUnit;

import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.junit.*;
import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class HTMLdriver {
	
	@Test
	public void HTML() throws Exception{
		
		HtmlUnitDriver driver = new HtmlUnitDriver();
		//driver.setJavascriptEnabled(true);
		
		driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
		
		String vURL = "http://www.pennywisesolutions.com";
		driver.get(vURL);  
			List<WebElement> imagesList = driver.findElements(By.tagName("img"));
			int countBrokenImages = 0;
			for (WebElement image : imagesList)
			{
			    HttpResponse response = new DefaultHttpClient().execute(new HttpGet(image.getAttribute("src")));
			    if (response.getStatusLine().getStatusCode() != 200){
			        // Do whatever you want with broken images
			    	String  currentImageUrl = image.getAttribute("src");
			    	System.out.println(currentImageUrl);
			    	countBrokenImages++;
			    }
			}	
			System.out.println("The number of Broken URLs are: " + countBrokenImages);
	}
	}